/* 
 * File:   ServerConfFileManagerTest.cpp
 * Author: nahuel
 *
 * Created on May 23, 2013, 10:24:34 PM
 */

#include <stdlib.h>
#include <iostream>
#include "common_ServerConfFileManager.h"

/*
 * Simple C++ Test Suite
 */

// Reemplazar con tu nombre de usuario!!!
const char* path = "/home/nahuel/Desktop/conf_server_test.xml";

void testServerConfFileManager() {
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    serverConfFileManager.SaveChanges();
    
    if (false /*check result*/) {
        std::cout << "%TEST_FAILED% time=0 testname=testServerConfFileManager (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}

void testSetPathAU() {
    const std::string& pathAu("/example/path/");
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    
    serverConfFileManager.SetPathAU(pathAu);    
    serverConfFileManager.SaveChanges();
    
    if (false /*check result*/) {
        std::cout << "%TEST_FAILED% time=0 testname=testSetPathAU (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}

void testSetPuertoServidor() {
    std::string puertoServidor = "1234";
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    
    serverConfFileManager.SetPuertoServidor(puertoServidor);
    serverConfFileManager.SaveChanges();
    
    if (false /*check result*/) {
        std::cout << "%TEST_FAILED% time=0 testname=testSetPuertoServidor (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}

void testSetTimeout() {
    unsigned int timeout = 1234;
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    
    serverConfFileManager.SetTimeoutClientes(timeout);
    serverConfFileManager.SaveChanges();
    
    if (false /*check result*/) {
        std::cout << "%TEST_FAILED% time=0 testname=testSetPuertoServidor (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}


void testGetPathAU() {
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    std::string result = serverConfFileManager.GetPathAU();
    
    if (result != "/example/path/"){
        std::cout << "%TEST_FAILED% time=0 testname=testGetPathAU (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}

void testGetPuertoServidor() {
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    std::string result = serverConfFileManager.GetPuertoServidor();
    if (result != "1234") {
        std::cout << "%TEST_FAILED% time=0 testname=testGetPuertoServidor (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}

void testGetTimeout() {
    const std::string& filePath(path);
    ServerConfFileManager serverConfFileManager(filePath);
    unsigned int result = serverConfFileManager.GetTimeoutClientes();
    if (result != 1234) {
        std::cout << "%TEST_FAILED% time=0 testname=testGetPuertoServidor (ServerConfFileManagerTest) message=error message sample" << std::endl;
    }
}

//void testSaveChanges() {
//    ServerConfFileManager serverConfFileManager;
//    serverConfFileManager.SaveChanges();
//    if (true /*check result*/) {
//        std::cout << "%TEST_FAILED% time=0 testname=testSaveChanges (ServerConfFileManagerTest) message=error message sample" << std::endl;
//    }
//}

int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% ServerConfFileManagerTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;
    
    std::cout << "%TEST_STARTED% testServerConfFileManager (ServerConfFileManagerTest)" << std::endl;
    testServerConfFileManager();
    std::cout << "%TEST_FINISHED% time=0 testServerConfFileManager (ServerConfFileManagerTest)" << std::endl;

    std::cout << "%TEST_STARTED% testSetPathAU (ServerConfFileManagerTest)" << std::endl;
    testSetPathAU();
    std::cout << "%TEST_FINISHED% time=0 testSetPathAU (ServerConfFileManagerTest)" << std::endl;

    std::cout << "%TEST_STARTED% testSetPuertoServidor (ServerConfFileManagerTest)" << std::endl;
    testSetPuertoServidor();
    std::cout << "%TEST_FINISHED% time=0 testSetPuertoServidor (ServerConfFileManagerTest)" << std::endl;
    
    std::cout << "%TEST_STARTED% testSetPuertoServidor (ServerConfFileManagerTest)" << std::endl;
    testSetTimeout();
    std::cout << "%TEST_FINISHED% time=0 testSetPuertoServidor (ServerConfFileManagerTest)" << std::endl;

    std::cout << "%TEST_STARTED% testGetPathAU (ServerConfFileManagerTest)" << std::endl;
    testGetPathAU();
    std::cout << "%TEST_FINISHED% time=0 testGetPathAU (ServerConfFileManagerTest)" << std::endl;

    std::cout << "%TEST_STARTED% testGetPuertoServidor (ServerConfFileManagerTest)" << std::endl;
    testGetPuertoServidor();
    std::cout << "%TEST_FINISHED% time=0 testGetPuertoServidor (ServerConfFileManagerTest)" << std::endl;

    std::cout << "%TEST_STARTED% testGetPuertoServidor (ServerConfFileManagerTest)" << std::endl;
    testGetTimeout();
    std::cout << "%TEST_FINISHED% time=0 testGetPuertoServidor (ServerConfFileManagerTest)" << std::endl;        

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

